/*
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-27 16:02:34
 * @LastEditTime: 2022-12-26 11:16:15
 */
import nameOpt from '@/biz/option/name.js'
import Opt from '@/components/dt/info/Opt.js'
import table from '@/components/dt/table/render.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [

      {
        field: 'userName',
        fixed: 'left',

        minWidth: 150,
        slots: {
          header: (params, h) => {
            return table.header.arrow(_this, h, nameOpt.createPeople({
              key: 'userName',
              title: _this.type == 'TOSPUR' ? '承接顾问' : '使用人',
              to: (info) => {
                return {
                  nameOrWorkNo: info.workNo,

                }
              }
            }))
          },
          default: (params, h) => {
            return table.cell.text(h, {
              value: params.row.userName
            })
          }
        }
      },
      {
        field: 'callType',
        minWidth: 120,
        header: {
          filter: {
            title: '呼叫类型',
            key: 'callType',
            placeholder: '请选择',
            select: {
              options: [
                { key: 1, value: '被叫' },
                { key: 0, value: '主叫' },
              ],
            }
          }
        }
      }, {
        field: 'unconnectedCause0',
        minWidth: 120,
        title: '是否接通',
        header: {
          filter: {
            title: '是否接通',
            key: 'unconnectedCause',
            placeholder: '请选择',
            select: {
              options: [
                { key: 0, value: '未接通' },
                { key: 1, value: '接通' },
              ],
            }
          }
        }
      },
      {
        field: 'phoneNo',
        minWidth: 130,

        header: {
          filter: {
            title: _this.type == 'privacy' ?'使用人手机号':'顾问手机号' ,
            key: 'phoneNo',
            placeholder: '请输入手机号码',
            input: {}
          }
        }
      }, {
        field: 'peerNo',
        minWidth: 130,
        header: {
          filter: {
            title: '客户手机号',
            key: 'peerNo',
            placeholder: '请输入手机号码',
            input: {}
          }
        }
      }, {
        field: 'secretNo',
        minWidth: 130,
        header: {
          filter: {
            title: '隐私号',
            key: 'secretNo',
            placeholder: '请输入手机号码',
            input: {}
          }
        }
      },
      {
        title: '主叫拨打时间',
        field: 'callTime',
        minWidth: 200,
      },
      // {
      //   field: 'isFirstPush',
      //   minWidth: 120,
      //   header: {
      //     filter: {
      //       title: '是否在案',
      //       key: 'isFirstPush',
      //       placeholder: '请选择是否在案',
      //       select: {
      //         options: [
      //           { key: 0, value: '离案' },
      //           { key: 1, value: '在案' },
      //         ],
      //       }
      //     }
      //   }
      // },
      {
        title: '电话时长',
        field: 'callDuration',
        minWidth: 150,
      }, {
        title: '未接通原因',
        field: 'unconnectedCauseN',
        minWidth: 150,
      },

      {
        title: '所属事业部',
        field: 'orgDivisionName',
        minWidth: 150,
      }, {
        title: '所属子公司',
        field: 'orgCompanyName',
        minWidth: 150,
      }, {
        title: '所属事业处',
        field: 'orgOfficeName',
        minWidth: 150,
      }, {
        title: '所属案场',
        field: 'buildingName',
        minWidth: 150,
      }, {
        title: '所属城市',
        field: 'city',
        minWidth: 150,
      },


      {
        title: '操作',
        fixed: 'right',
        visible: _this.type != 'LEASE',
        width: 140,
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []
            let btnFlag = params.row.unconnectedCause0 == '接通' && params.row.recordUrl
            btns.push({
              title: btnFlag ? '播放' : '-',
              event: btnFlag && 'audioPlay',
              data: params.row
            })

            btns.push({
              title: btnFlag ? '下载' : '-',
              event: btnFlag && 'audioDownload',
              data: params.row
            })
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }

}

export default Column